package com.itboye.eweilisten.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.eweilisten.R;
import com.itboye.eweilisten.model.AddressBean;

import java.util.List;

/**
 * Created by itboye on 2017/3/9.
 */

public class XueXiaoAdapter extends BaseAdapter {
    Context context;
    List<AddressBean> bean;
    int seletepostion=-1;

    public XueXiaoAdapter(Context context, List<AddressBean> bean) {
        this.context = context;
        this.bean = bean;
    }

    @Override
    public int getCount() {
        return bean.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public void getPositon(int positon){
       this. seletepostion=positon;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHouer houer;
        if (convertView == null) {
            houer = new ViewHouer();
            convertView = LayoutInflater.from(context).inflate(R.layout.dialog_item_xuexiao, null);
            houer.name = (TextView) convertView.findViewById(R.id.tvNianji);
            convertView.setTag(houer);
        } else {
            houer = (ViewHouer) convertView.getTag();
        }
//        houer.name.setTextColor(getResources(getColor(R.color.gray)));
        if(seletepostion==position){
            houer.name.setTextColor(Color.parseColor("#009ff0"));
        }else{
            houer.name.setTextColor(Color.parseColor("#808080"));
        }
        houer.name.setText(bean.get(position).getName());
        return convertView;
    }

    class ViewHouer {
        TextView name;
    }


}
